// pages/services/index.js
var app = getApp(), fetchApi = require("../../utils/httpPost.js");
import Toast from '../../component/vant/toast/toast';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    menus:[],
    loading: false,
    netWork: true,
    isLoading: true,
    netWork:false,
    hasData:false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  },
  goShowBuild(){
    Toast('工程师正加紧建设中...');
  },
  /**
   * 获取页面数据的 http请求
   */
  onHttpInit: function () {
    var that = this
    fetchApi.httpPost('/titleMenu/service', {
      menu_type:0,
      service_type:'property'
    }, function (res) {
      if (res.data.code == 0) {
        if (res.data.totalcount > 0) {
          console.log("服务列表", res)
          that.setData({
            hasData: true,
            menus: res.data.data.menus
          })
        }
      }
      that.setData({
         isLoading: false, loading: true, netWork: true,
      })
    }, function (res) {
        that.setData({ hasData: false,  isLoading: false,  loading: true, netWork: true })
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    //自定义的tabbar
    // if (typeof this.getTabBar === 'function' &&
    //   this.getTabBar()) {
    //   this.getTabBar().setData({
    //     selected: 1
    //   })
    // }
    app.getCurrentTabbar(1,this);
    
    this.onHttpInit();
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },
})